home *** CD-ROM | disk | FTP | other *** search
- /* swap2.c: A working swap function */
- #include <stdio.h>
-
- void swap(int *, int *);
-
- main()
- {
- int i = 7, j = 8;
-
- swap(&i,&j);
- printf("i == %d, j == %d\n",i,j);
- return 0;
- }
-
- void swap(int *xp, int *yp)
- {
- int temp = *xp;
- *xp = *yp;
- *yp = temp;
- }
-
- /* OUTPUT:
- * i == 8, j == 7 */
-
-